package com.xique.park.controller.auto;

import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkConfig;
import com.xique.park.service.service.IParkConfigService;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.page.TableDataInfo;

/**
 * 【车辆更新记录】Controller
 * 
 * @author xique
 * @date 2021-12-14
 */
@RestController
@RequestMapping("/config")
public class ParkConfigController extends BaseController
{
    @Autowired
    private IParkConfigService parkConfigService;

    /**
     * 查询【车辆更新记录】列表
     */
    @PreAuthorize(hasPermi = "park:config:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkConfig parkConfig)
    {
        startPage();
        List<ParkConfig> list = parkConfigService.selectParkConfigList(parkConfig);
        return getDataTable(list);
    }

    /**
     * 导出【车辆更新记录】列表
     */
    @PreAuthorize(hasPermi = "park:config:export")
    @Log(title = "【车辆更新记录】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkConfig parkConfig) throws IOException
    {
        List<ParkConfig> list = parkConfigService.selectParkConfigList(parkConfig);
        ExcelUtil<ParkConfig> util = new ExcelUtil<ParkConfig>(ParkConfig.class);
        util.exportExcel(response, list, "【车辆更新记录】数据");
    }

    /**
     * 获取【车辆更新记录】详细信息
     */
    @PreAuthorize(hasPermi = "park:config:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(parkConfigService.selectParkConfigById(id));
    }

    /**
     * 新增【车辆更新记录】
     */
    @PreAuthorize(hasPermi = "park:config:add")
    @Log(title = "【车辆更新记录】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkConfig parkConfig)
    {
        return toAjax(parkConfigService.insertParkConfig(parkConfig));
    }

    /**
     * 修改【车辆更新记录】
     */
    @PreAuthorize(hasPermi = "park:config:edit")
    @Log(title = "【车辆更新记录】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkConfig parkConfig)
    {
        return toAjax(parkConfigService.updateParkConfig(parkConfig));
    }

    /**
     * 删除【车辆更新记录】
     */
    @PreAuthorize(hasPermi = "park:config:remove")
    @Log(title = "【车辆更新记录】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        List<Long> idList = Arrays.asList(ids);
        return toAjax(parkConfigService.deleteParkConfigByIds(idList));
    }
}
